package com.example.book.mapper;

import com.example.book.dto.BookDTO;
import com.example.book.dto.BookPageDTO;
import com.example.book.dto.BorrowPageDTO;
import com.example.book.entity.Book;
import com.example.book.entity.Borrow;
import com.example.book.entity.User;
import com.example.book.vo.BookVO;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface BookMapper {
    Page<BookVO> page(BookPageDTO bookPageDTO);
    @Select("select * from book where book_name=#{bookNmae}")
    Book getBookByBookName(String bookName);
    @Insert("insert into book (book_name, category_id, book_number, status, create_time, update_time) " +
            "VALUES" +
            "(#{bookName},#{categoryId},#{bookNumber},#{status},#{createTime},#{updateTime}) ")
    void insertBook(Book book);
    @Update("update book set book_number = book_number+#{bookNumber} where book_name=#{bookName}")
    void updateBookMeg(Book book);

    List<Integer> getBookMegByBookName(List<String> bookName);

    void updateBookNumberMeg(List<Borrow> borrows);
    //删除图书的信息
    void deleteBookMeg(List<String> bookName);
    @Update("update book set book_number = book_number + 1 where book_name = #{bookName}")
    void updateBookMegByBorrow(String bookName);
}
